/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "gpi_kpi")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GpiKpi.findAll", query = "SELECT g FROM GpiKpi g"),
    @NamedQuery(name = "GpiKpi.findById", query = "SELECT g FROM GpiKpi g WHERE g.id = :id"),
    @NamedQuery(name = "GpiKpi.findByType", query = "SELECT g FROM GpiKpi g WHERE g.type = :type"),
    @NamedQuery(name = "GpiKpi.findByName", query = "SELECT g FROM GpiKpi g WHERE g.name = :name"),
    @NamedQuery(name = "GpiKpi.findByArchitecturalLayer", query = "SELECT g FROM GpiKpi g WHERE g.architecturalLayer = :architecturalLayer"),
    @NamedQuery(name = "GpiKpi.findByConceptualLayer", query = "SELECT g FROM GpiKpi g WHERE g.conceptualLayer = :conceptualLayer"),
    @NamedQuery(name = "GpiKpi.findByUpdateFrequency", query = "SELECT g FROM GpiKpi g WHERE g.updateFrequency = :updateFrequency"),
    @NamedQuery(name = "GpiKpi.findByDefinitionTime", query = "SELECT g FROM GpiKpi g WHERE g.definitionTime = :definitionTime"),
    @NamedQuery(name = "GpiKpi.findByExternalLinkToFormula", query = "SELECT g FROM GpiKpi g WHERE g.externalLinkToFormula = :externalLinkToFormula"),
    @NamedQuery(name = "GpiKpi.findByIndicatorClassification", query = "SELECT g FROM GpiKpi g WHERE g.indicatorClassification = :indicatorClassification")})
public class GpiKpi implements Serializable {
    @Column(name = "DefinitionTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date definitionTime;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "Type")
    private String type;
    @Column(name = "Name")
    private String name;
    @Column(name = "ArchitecturalLayer")
    private String architecturalLayer;
    @Column(name = "ConceptualLayer")
    private String conceptualLayer;
    @Column(name = "UpdateFrequency")
    private BigInteger updateFrequency;
    @Basic(optional = false)
    @Column(name = "ExternalLinkToFormula")
    private String externalLinkToFormula;
    @Column(name = "IndicatorClassification")
    private String indicatorClassification;
    @JoinTable(name = "predicate_gpi_kpi", joinColumns = {
        @JoinColumn(name = "Id_GPI_KPI", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "Id_Predicate", referencedColumnName = "ID")})
    @ManyToMany
    private Collection<Predicate> predicateCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gpiKpi")
    private Collection<Consequent> consequentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gpiKpi")
    private Collection<Thresholds> thresholdsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idGPIKPI")
    private Collection<GpiKpiInstance> gpiKpiInstanceCollection;
    @OneToMany(mappedBy = "idReferredGPIKPI")
    private Collection<GpiKpiInstance> gpiKpiInstanceCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idGPIKPIViolated")
    private Collection<ExecutedRules> executedRulesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gpiKpi")
    private Collection<Antecedent> antecedentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idGPIKPI2")
    private Collection<Correlation> correlationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idGPIKPI1")
    private Collection<Correlation> correlationCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idGPIKPI")
    private Collection<StoredValues> storedValuesCollection;

    public GpiKpi() {
    }

    public GpiKpi(String id) {
        this.id = id;
    }

    public GpiKpi(String id, String externalLinkToFormula) {
        this.id = id;
        this.externalLinkToFormula = externalLinkToFormula;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getArchitecturalLayer() {
        return architecturalLayer;
    }

    public void setArchitecturalLayer(String architecturalLayer) {
        this.architecturalLayer = architecturalLayer;
    }

    public String getConceptualLayer() {
        return conceptualLayer;
    }

    public void setConceptualLayer(String conceptualLayer) {
        this.conceptualLayer = conceptualLayer;
    }

    public BigInteger getUpdateFrequency() {
        return updateFrequency;
    }

    public void setUpdateFrequency(BigInteger updateFrequency) {
        this.updateFrequency = updateFrequency;
    }

    public String getExternalLinkToFormula() {
        return externalLinkToFormula;
    }

    public void setExternalLinkToFormula(String externalLinkToFormula) {
        this.externalLinkToFormula = externalLinkToFormula;
    }

    public String getIndicatorClassification() {
        return indicatorClassification;
    }

    public void setIndicatorClassification(String indicatorClassification) {
        this.indicatorClassification = indicatorClassification;
    }

    @XmlTransient
    public Collection<Predicate> getPredicateCollection() {
        return predicateCollection;
    }

    public void setPredicateCollection(Collection<Predicate> predicateCollection) {
        this.predicateCollection = predicateCollection;
    }

    @XmlTransient
    public Collection<Consequent> getConsequentCollection() {
        return consequentCollection;
    }

    public void setConsequentCollection(Collection<Consequent> consequentCollection) {
        this.consequentCollection = consequentCollection;
    }

    @XmlTransient
    public Collection<Thresholds> getThresholdsCollection() {
        return thresholdsCollection;
    }

    public void setThresholdsCollection(Collection<Thresholds> thresholdsCollection) {
        this.thresholdsCollection = thresholdsCollection;
    }

    @XmlTransient
    public Collection<GpiKpiInstance> getGpiKpiInstanceCollection() {
        return gpiKpiInstanceCollection;
    }

    public void setGpiKpiInstanceCollection(Collection<GpiKpiInstance> gpiKpiInstanceCollection) {
        this.gpiKpiInstanceCollection = gpiKpiInstanceCollection;
    }

    @XmlTransient
    public Collection<GpiKpiInstance> getGpiKpiInstanceCollection1() {
        return gpiKpiInstanceCollection1;
    }

    public void setGpiKpiInstanceCollection1(Collection<GpiKpiInstance> gpiKpiInstanceCollection1) {
        this.gpiKpiInstanceCollection1 = gpiKpiInstanceCollection1;
    }

    @XmlTransient
    public Collection<ExecutedRules> getExecutedRulesCollection() {
        return executedRulesCollection;
    }

    public void setExecutedRulesCollection(Collection<ExecutedRules> executedRulesCollection) {
        this.executedRulesCollection = executedRulesCollection;
    }

    @XmlTransient
    public Collection<Antecedent> getAntecedentCollection() {
        return antecedentCollection;
    }

    public void setAntecedentCollection(Collection<Antecedent> antecedentCollection) {
        this.antecedentCollection = antecedentCollection;
    }

    @XmlTransient
    public Collection<Correlation> getCorrelationCollection() {
        return correlationCollection;
    }

    public void setCorrelationCollection(Collection<Correlation> correlationCollection) {
        this.correlationCollection = correlationCollection;
    }

    @XmlTransient
    public Collection<Correlation> getCorrelationCollection1() {
        return correlationCollection1;
    }

    public void setCorrelationCollection1(Collection<Correlation> correlationCollection1) {
        this.correlationCollection1 = correlationCollection1;
    }

    @XmlTransient
    public Collection<StoredValues> getStoredValuesCollection() {
        return storedValuesCollection;
    }

    public void setStoredValuesCollection(Collection<StoredValues> storedValuesCollection) {
        this.storedValuesCollection = storedValuesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GpiKpi)) {
            return false;
        }
        GpiKpi other = (GpiKpi) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.GpiKpi[ id=" + id + " ]";
    }

    public Date getDefinitionTime() {
        return definitionTime;
    }

    public void setDefinitionTime(Date definitionTime) {
        this.definitionTime = definitionTime;
    }
    
}
